package com.whcoding.designpatterns.pattern.strategy;

/**
 * @program: spring-boot-learning
 * @description:
 * @author: whcoding
 * @create: 2022-09-20 20:09
 **/
public class StrategyTests {

	public static void main(String[] args) {

		BookVO book1 = new BookVO("java设计模式", new NoDiscountStrategy());
		book1.getDiscount();

		FlatRateStrategy rateStrategy = new FlatRateStrategy(23.0, 5);
		//设置折扣金额为1元/本
		rateStrategy.setDiscountPrice(1);
		BookVO book2 = new BookVO("java与模式",rateStrategy);
		book2.getDiscount();

		System.out.println("修改《java与模式》的折扣算法：");
		PercentageStrategy percentageStrategy = new PercentageStrategy(23, 5);
		//设置折扣为70%
		percentageStrategy.setDiscountPercent(0.07);
		book2.setStrategy(percentageStrategy);
		book2.getDiscount();

	}
}
